<?php
App::uses('AppModel', 'Model');

class NaoLido extends AppModel {

	//The Associations below have been created with all possible keys, those that are not needed can be removed

/**
 * belongsTo associations
 *
 * @var array
 */
	public $belongsTo = array(
		'Users' => array(
			'className' => 'User',
			'foreignKey' => 'users_id',
		),
		'Tarefa' => array(
			'className' => 'Tarefa',
			'foreignKey' => 'tarefas_id',
		),
		'Mensagens' => array(
			'className' => 'Mensagem',
			'foreignKey' => 'mensagens_id',
		)
	);
	
	public function numero_nao_lidas($id){
		return $this->find('count', array('conditions'=>array('NaoLidas.users_id'=>$id)));
	}
	
	public function mensagensNaoLidasPorProjeto($id){
		return $this->findAllByUsersId($id, array(), array("Tarefa.projetos_id ASC"));
	}
}
